/**
 * Project Name:hyh-web
 * File Name:UserRepositoryImpl.java
 * Package Name:com.hyh.repository.impl
 * Date:2018年9月5日下午3:15:54
 *
*/

package com.hyh.repository.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.hyh.model.entity.User;
import com.hyh.repository.UserRepository;

/**
 * ClassName:UserRepositoryImpl
 * Reason:	 TODO ADD REASON.
 * Date:     2018年9月5日 下午3:15:54
 * @author   huangyihao
 * @version  
 * @see 	 
 */
@Repository
public class UserRepositoryImpl implements UserRepository {
	
	private static List<User> userList = new ArrayList<>();
	
	@Override
	public User add(User user) {
		userList.add(user);
		return user;
	}

	@Override
	public List<User> all() {
		return userList;
	}

	@Override
	public User findById(Long id) {
		return userList.stream().filter(u -> id.equals(u.getId())).findFirst().orElse(null);
	}

}
